#coding=utf-8

from datetime import timedelta

# 默认配置
class DefaultConfig():
    # 数据库的配置变量
    HOSTNAME = '127.0.0.1'
    PORT = '3306'
    DATABASE = 'student_manager'
    USERNAME = 'mysouil'
    PASSWORD = '123456'
    DB_URI = 'mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8'.format(USERNAME, PASSWORD, HOSTNAME, PORT, DATABASE)
    
    SQLALCHEMY_DATABASE_URI = DB_URI
    # 不需要跟踪数据库数据的修改
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    SECRET_KEY = 'please-generate-a-random-secret_key'

    # 设置session有效时间为30分钟
    PERMANENT_SESSION_LIFETIME = timedelta(minutes=30)
    
# 开发环境的配置
class DevelopmentConfig(DefaultConfig):
    DEBUG = True
    # 打印sql
    SQLALCHEMY_ECHO = True

# 生产环境的配置信息
class ProductConfig(DefaultConfig):
    pass

# 把不同的环境配置和字符串串联起来
map_config = {
    'develop':DevelopmentConfig,
    'product':ProductConfig
}
